package com.xzy.dao;

import com.xzy.entity.Hole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component(value = "HoleMapper")
public interface HoleMapper {
    @Insert("insert into hole(holeTitle,holeContent,holeType,userId) values (#{holeTitle},#{holeContent},#{holeType},#{userId})")
    void addHole(Hole hole);

    @Update("update hole set holeTitle=#{holeTitle},holeContent=#{holeContent},holeType=#{holeType} where holeId=#{holeId}")
    void updateHole(Hole hole);

    @Select("select * from hole where holeType like #{holeType}")
    List<Hole> getHoleByType(String holeType);

    @Select("select * from hole")
    List<Hole> findAll();

    @Select("select * from hole where holeId=#{holeId}")
    Hole getHoleById(int holeId);

    @Delete("delete from hole where holeId=#{holeId}")
    void deleteHole(int holeId);
}
